#ifndef __IBT_FB_H__
#define __IBT_FB_H__

#include "IBT_Common.h"
#include <fcntl.h>
#include <linux/fb.h>
#include <malloc.h>
#include <string.h>


#define MAX_DESC_NUM                2
#define MAX_LAYER_NUM               2
#define MAX_BITS_PER_PIX           (32)


struct IBTFbHandler {
	IBTHandler  *ibtHandler;
	IBTEventCallback event;
	IBT_PTR		priv[0];
};

/*add jz_fb start*/
enum {
	LAYER_CFG_FORMAT_RGB555 = 0,
	LAYER_CFG_FORMAT_ARGB1555 = 1,
	LAYER_CFG_FORMAT_RGB565	= 2,
	LAYER_CFG_FORMAT_RGB888	= 4,
	LAYER_CFG_FORMAT_ARGB8888 = 5,
	LAYER_CFG_FORMAT_NV12 = 8,
	LAYER_CFG_FORMAT_NV21 = 9,
	LAYER_CFG_FORMAT_YUV422 = 10,
	LAYER_CFG_FORMAT_TILE_H264 = 12,
};

enum {
	LAYER_CFG_COLOR_RGB = 0,
	LAYER_CFG_COLOR_RBG = 1,
	LAYER_CFG_COLOR_GRB = 2,
	LAYER_CFG_COLOR_GBR = 3,
	LAYER_CFG_COLOR_BRG = 4,
	LAYER_CFG_COLOR_BGR = 5,
};

struct jzfb_lay_cfg {
	unsigned int lay_en;
	unsigned int lay_z_order;
	unsigned int pic_witdh;
	unsigned int pic_height;
	unsigned int disp_pos_x;
	unsigned int disp_pos_y;
	unsigned int g_alpha_en;
	unsigned int g_alpha_val;
	unsigned int color;
	unsigned int domain_multi;
	unsigned int format;
	unsigned int stride;
};

struct jzfb_frm_cfg {
	struct jzfb_lay_cfg lay_cfg[MAX_LAYER_NUM];
};

struct jzfb_layer_csc_t {
	enum csc_mode {
		CSC_MODE_0,
		CSC_MODE_1,
		CSC_MODE_2,
		CSC_MODE_3,
	} csc_mode;
	uint8_t layer;
};

struct jzfb_dev{
	struct jzfb_frm_cfg frm_cfg;
	struct jzfb_layer_csc_t layer_csc[MAX_LAYER_NUM];
	int lcd_type;
	unsigned int data_buf[MAX_DESC_NUM][MAX_LAYER_NUM];
	unsigned int num_buf;
	void *buf_addr;

	int width;
	int height;

	unsigned int vid_size;
	unsigned int fb_size;
	int bpp;
	int format;

	struct fb_fix_screeninfo fix_info;
	struct fb_var_screeninfo var_info;

	int fd;
};


#define JZFB_PUT_FRM_CFG		_IOWR('F', 0x101, struct jzfb_frm_cfg *)
#define JZFB_GET_FRM_CFG		_IOWR('F', 0x102, struct jzfb_frm_cfg *)

#define JZFB_CMP_START			_IOW('F', 0X141, int)
#define JZFB_TFT_START			_IOW('F', 0X143, int)
#define JZFB_SLCD_START			_IOW('F', 0X144, int)
#define JZFB_GEN_STP_CMP		_IOW('F', 0x145, int)
#define JZFB_QCK_STP_CMP		_IOW('F', 0x147, int)
#define JZFB_PRINT_LAY_SITE		_IOW('F', 0x149, int)
#define JZFB_SET_CSC_MODE		_IOW('F', 0x120, struct jzfb_layer_csc_t)
/*add jz_fb end*/


IBTFbHandler *IBT_Fb_Init(IBTHandler *ibtHandler);
IBT_VOID IBT_Fb_DeInit(IBTFbHandler *h);

#endif
